
import random
import os

filename = 'question.txt'


def openfile():
    
    """
    操作文件,提取内容
     
    """   
    dic = {}
    
    if os.path.exists(filename):
        with open(filename, encoding='utf-8') as f:
            for line in f:
                line = line.strip().replace('\t', ' ').split('. ')
                dic[line[0]] = line[1]
            return dic


dic = openfile()

while True:
    
    l = []    
    for i in range(1, 9):
        l.append(i)
    question = random.choice(list(dic.keys()))
    print(dic[question])
    num = random.choice(l)
    print("%s号作答" % num)
    dic.pop(question)
    inp = input('请打分')
    if not dic:
        break
